<!--
 * @Author: mayufo
 * @Date: 2020-02-14 18:12:34
 * @LastEditTime : 2020-02-14 18:33:54
 * @Description: 
 * @FilePath: /node/05/code/2-封装ajax.html
 -->
<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        function get(url, callback) {
            var oReq = new XMLHttpRequest();
            // 当请求加载成功调用指定的函数 http-server
            oReq.onload = function xxx() {
                callback(oReq.responseText)
            }
            oReq.open("get", "data.json", true);
            oReq.send();
        }
        get('data.json', (data) => {
            console.log(data, 55)
        })

    </script>
</body>

</html>